package com.yun.datastructure.graph;

import com.yun.datastructure.graph.domain.Edge;
import com.yun.datastructure.graph.domain.Vertex;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class TopologicalSortDFS {

    private static void dfs(Vertex v,LinkedList<String> stack){
        if(v.status==2){
            return;
        }
        if(v.status==1){
            throw new RuntimeException("发现了环");
        }
        v.status=1;
        for (Edge edge : v.edges) {
            dfs(edge.linked,stack);
        }
        v.status=2;
        stack.push(v.name);
    }
}
